from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.webapp.util import run_wsgi_app
import simplejson as json
import createDB
from xmlrpclib import datetime

#getting a comment and passing it to a JSON object
class getComments(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        comments = db.GqlQuery("SELECT * from Comments")
        result = [{'placeName': str(comment.placeName), 'comment': str(comment.comment), 'date': str(comment.date)} for comment in comments]
        
        
        self.response.out.write(json.dumps(result))
        
application = webapp.WSGIApplication([('/getComments', getComments)], debug=True)
  
def main():
    run_wsgi_app(application)
    
if __name__ == "__main__":
    main()